<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/Css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/Css/weui.min.css" />
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<form class="form-inline definewidth m20" action="#" method="get">    
    OPENID：
    <input type="text" name="username" id="username"class="abc input-default" placeholder="" value="">&nbsp;&nbsp;  
    <button type="submit" class="btn btn-primary">查询</button>

</form>
<table class="table table-bordered table-hover definewidth m10">
 <thead>
    <tr>
        <th>编号</th>
         <th>活动编号</th>
        <th>微信OPENID</th>
        <th>用户生活照</th>
        <th>真实姓名</th>
        <th>性别</th>
        <th>联系方式</th>
        <th>审核</th>
    </tr>
    </thead>
<c:forEach items="${users}" var="user" varStatus="status" >
			
	     <tr>
	        <td>${status.count }</td>
	        <td class="activeid">${user.activeid }</td>
            <td class="openid">${user.openid }</td>
            <td> <img src="${user.image_url }" /> </td>
            <td>${ user.name}</td>
            <td>
            	<c:choose>
            		<c:when test="${user.sex==1}">
            			男
            		</c:when>
            		<c:otherwise>
            			女
            		</c:otherwise>
            	</c:choose>
           </td>
            <td>${user.telphone }</td>
            <td>
                 <button type="button" class="btn btn-info agree-btn" ><i class="icon-ok"></i></button>
                  <button type="button" class="btn btn-danger refuse-btn" ><i class="icon-remove"></i></button>
            </td>
        </tr>	    
     </c:forEach>
</table>

   <!--BEGIN toast-->
    <div id="toast" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-icon-success-no-circle weui-icon_toast"></i>
            <p class="weui-toast__content"></p>
        </div>
    </div>
    <!--end toast-->
  
   <script type="text/javascript" src="<%=request.getContextPath()%>/Js/jquery.js"></script>
   
  <script type="text/javascript">
  
  		$(document).ready(function(){
  			
  	      var $toast = $('#toast'); 
  	      
  			$('.agree-btn').click(function(e){
  	  			var activeid = $(this).parent().parent().find(".activeid").text();
  	  		    var openid = $(this).parent().parent().find(".openid").text();
  	  		    var $tr= $(this).parent().parent();
  	  		    var audit = 1;
  	  		    var url = "<%=request.getContextPath()%>/admin/audit";
  	  	
  	  		  
  	  			$.post(url,{"activeid":activeid,"openid":openid,"audit":audit},function(response){
  	  		  		var response = $.parseJSON(response);
  	  		  		if(response.result=="200"){
  	  		  	           $tr.remove();
  	  		  				$('.weui-toast__content').html("审核完成");
  	  		  			   
	  	  		  		  setTimeout(function () {
		  	  				 $toast.fadeIn(100);
		  	  	         }, 2000);
		  	  	           $toast.fadeIn(100);
		  	  	           setTimeout(function () {
		  	  	               $toast.fadeOut(100);
		  	  	           }, 2000);
  	  		  			
  	  		  		}else{
	  	  		  		 setTimeout(function () {
	  	  		  		$('.weui-toast__content').html("审核失败");
		  	  				 $toast.fadeIn(100);
		  	  	         }, 2000);
		  	  	           $toast.fadeIn(100);
		  	  	           setTimeout(function () {
		  	  	               $toast.fadeOut(100);
		  	  	           }, 2000);
  	  		  		}
	  	  			
  	  			}); 
  	  		});
  			
  			
  			$('.refuse-btn').click(function(e){
  	  			var activeid = $(this).parent().parent().find(".activeid").text();
  	  		    var openid = $(this).parent().parent().find(".openid").text();
  	  		    var $tr= $(this).parent().parent();
  	  		    var audit = 2;
  	  		    var url = "<%=request.getContextPath()%>/admin/audit";
  	  	
  	  		  
  	  			$.post(url,{"activeid":activeid,"openid":openid,"audit":audit},function(response){
  	  		  		var response = $.parseJSON(response);
  	  		  		if(response.result=="200"){
  	  		  	           $tr.remove();
  	  		  				$('.weui-toast__content').html("操作成功，该用户已被拒绝通过");
  	  		  			   
	  	  		  		  setTimeout(function () {
		  	  				 $toast.fadeIn(100);
		  	  	         }, 2000);
		  	  	           $toast.fadeIn(100);
		  	  	           setTimeout(function () {
		  	  	               $toast.fadeOut(100);
		  	  	           }, 2000);
  	  		  			
  	  		  		}else{
	  	  		  		 setTimeout(function () {
	  	  		  		$('.weui-toast__content').html("审核失败");
		  	  				 $toast.fadeIn(100);
		  	  	         }, 2000);
		  	  	           $toast.fadeIn(100);
		  	  	           setTimeout(function () {
		  	  	               $toast.fadeOut(100);
		  	  	           }, 2000);
  	  		  		}
	  	  			
  	  			}); 
  	  		});
  			
  			
  		});
  	

     
	 </script>
	
</body>
</html>
